//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web;
using System.Web.UI;
using CommunityServer.Components;


namespace CommunityServer.Controls {

	// *********************************************************************
	//  StyleSkin
	//
	/// <summary>
	/// Encapsulated rendering of script based on the selected skin.
	/// </summary>
	// ********************************************************************/ 
	public class Script : LiteralControl {

		[
		System.ComponentModel.DefaultValue( "Utility/global.js" ),
		]
		public virtual String Src {
			get {
				Object state = ViewState["Src"];
				if ( state != null ) {
					return (String)state;
				}
				return "Utility/global.js";
			}
			set {
				ViewState["Src"] = value;
			}
		}
        
        const string srcFormat = "<script src=\"{0}/{1}?Version={2}\" type=\"text/javascript\"></script>";

        protected override void Render(HtmlTextWriter writer)
        {
            writer.Write( srcFormat, Globals.ApplicationPath, Src, SiteStatistics.CommunityServerVersion.ToString() );
        }


	}
}